﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
namespace EC21_EDiamond
{
    public partial class DoiMatKhauKhachHang : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null)
            {
                Response.Redirect("~/dangnhap.aspx");
            }
        }

        protected void btnDongY_Click(object sender, EventArgs e)
        {
            if (Membership.ValidateUser(Session["user"].ToString(), txtMatKhauCu.Text) == true)
            {
                lblThongBao.Text = "";
                Membership.GetUser(Session["user"].ToString()).ChangePassword(Membership.GetUser(Session["user"].ToString()).ResetPassword(), txtMatKhauMoi.Text);
                Session["user"] = null;
                Response.Redirect("~/dangnhap.aspx");
            }
            else
            {
                lblThongBao.Text = "Mật Khẩu Cũ Không Đúng";
                return;
            }
        }
    }
}